const { defineConfig } = require('@vue/cli-service')

// 从环境变量获取配置，默认值保持原有设置
const API_HOST = process.env.VUE_APP_API_HOST || 'localhost'
const API_PORT = process.env.VUE_APP_API_PORT || 8000
const API_BASE_URL = process.env.VUE_APP_API_BASE_URL || `http://${API_HOST}:${API_PORT}`

const DEV_SERVER_PORT = process.env.VUE_APP_DEV_SERVER_PORT || 8080

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    host: '0.0.0.0',
    port: DEV_SERVER_PORT,
    proxy: {
      '/api': {
        target: API_BASE_URL,
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
  }
})